package class1;

import java.util.Scanner;

public class demo4 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int tot=in.nextInt();
        int sum=0;
        int max=0;
        int []arr=new int[n];
        for (int i = 0; i <n ; i++) {
            arr[i]=in.nextInt();
            sum+=arr[i];
            max=Math.max(arr[i],max);
        }
        int l=1,r=max;
        while(l<r){
            int mid=l+(r-l)/2;
            int newSum=0;
            for (int i = 0; i <n ; i++) {
                newSum+=Math.min(arr[i],mid);
            }

            if(newSum<=tot){
                l=mid;
            }else {
                r=mid-1;
            }
        }
        System.out.println(l<=max?l:-1);
    }
}
